<?php
// Got the information from install1.php and now we have to do something with it

$sqlserver = $_POST['sqlserver'];
$sqlport   = $_POST['sqlport'];
$sqluser   = $_POST['sqluser'];
$sqlpassword = $_POST['sqlpass'];
$sqldb	   = $_POST['sqldb'];
$fullurl   = $_POST['fullurl'];

// Got them in variables.. Check some of them.

if(!is_numeric($sqlport)){ // Make sure they entered a number in the port field
	die("MySQL Port must be a number.");
	// If it isn't, die.
}

if(!$sqlpassword){
	die("You need to supply a password for the MySQL server.");
}

// So, all's well and we haven't die()'d yet.. Lets continue.
// We're just writing this to a file, so we can use ttech's backend thing

if(is_writable("../configuration.php")){
	file_put_contents("../configuration.php","<?php\n"); // <?php
	file_put_contents("../configuration.php","\$sqlserver = \"$sqlserver\";\n",FILE_APPEND); // $sqlserver = "<input>";
	file_put_contents("../configuration.php","\$sqlport = \"$sqlport\";\n",FILE_APPEND); // $sqlport = "<input>";
	file_put_contents("../configuration.php","\$sqluser = \"$sqluser\";\n",FILE_APPEND); // $sqluser = "<input>";
	file_put_contents("../configuration.php","\$sqlpassword = \"$sqlpassword\";\n",FILE_APPEND); // $sqlpassword = "<input>";
        file_put_contents("../configuration.php","\$sqldb = \"$sqldb\";\n",FILE_APPEND); // $sqldb = "<input>";
        file_put_contents("../configuration.php","\$fullurl = \"$fullurl\";\n",FILE_APPEND); // $fullurl = "<input>";

	// Dont write the closing php mark, for later versions... Upgrading, etc.
	header( 'Location: install3.php') ; // Next page..
} else {
	die("Sorry, the file configuration file is not writable. Please 'chmod 777 /dir/to/qdb/../configuration.php'");
}

// done. 

?>


